<template>
  <div>
    <ul>
      <li v-for="item in arr" :key="item">
        {{ item }}
      </li>
    </ul>
    <button @click="fn" :class="{ red: res }">增加</button>
    <button @click="revBtn">翻转</button>
    <button @click="updateBtn" :style="{ color: red }">更新第一个元素</button>
    <button @click="addBtn" :style="{ color: 'red' }">插入</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["赵今麦", "鞠婧祎", "张婧怡"],
      res: true,
      red: "red",
    };
  },
  methods: {
    revBtn() {
      this.arr.reverse();
    },

    updateBtn() {
      this.$set(this.arr, 0, "赵今麦老婆");
    },
    fn() {
      this.arr.push("迪丽热巴");
    },
    addBtn() {
      this.arr.splice(1, 0, "迪丽热巴");
    },
  },
};
</script>

<style scoped>
.red {
  color: red;
}
</style>>
</style>